define([ "marionette", "vent","views/messageView", "views/${domainClass}TableView", "views/${domainClass}DetailsView"], function(Marionette, vent, MessageView, TableView, DetailsView) {
	
	var ${capDomainClass}App;
	
	if(!${capDomainClass}App){
		
		${capDomainClass}App = new Marionette.Application();

		${capDomainClass}App.addRegions({
			messageContainer : "#message-container",
			tableContainer : "#table-container",
			detailsContainer: "#details-container"
		});

		
		${capDomainClass}App.addInitializer(function(options) {
		
			//\$(this.messageContainer.el).hide();
					
			// Show main app
			this.tableContainer.show(new TableView());
		
		});
	}
	
	vent.on("showMessage", function(title, message, level) {
		
		if(!level){
			level = 'danger';
		}
		
		var errorModel =  new Backbone.Model({
				title:title, 
				message:message,
				level:level
		});
		
		${capDomainClass}App.messageContainer.show(new MessageView({model:errorModel}));
		
		\$(${capDomainClass}App.messageContainer.el).show();
	}); 
	
	vent.on("show${capDomainClass}Details", function(model) {
		
		${capDomainClass}App.detailsContainer.show(new DetailsView({model:model}));
	});


	vent.on("showTestDetails", function(model) {
		
		${capDomainClass}App.detailsContainer.show(new DetailsView({model:model}));
	});
	
	vent.on("added${capDomainClass}", function(model) {
		
		${capDomainClass}App.detailsContainer.show(new DetailsView({model:model}));
		
		vent.trigger('setActive${capDomainClass}',  model);
	});

	
	return ${capDomainClass}App;
});
